package com.rfs.suanfa;

public class 找出重复的数和丢失的数 {
    public static void main(String[] args) {


    }
//[2,2,3,4]
    public static int[] findErrorNums(int[] nums) {
        int[] counter=new int[nums.length+1];
        for (int i : nums) {
            counter[i]++;
        }
        int[] result = new int[2];
        for (int i = 1; i < counter.length; i++) {
            if (counter[i] == 0) {
                result[1]=i;
            }else if(counter[i]==2){
                result[0]=i;
            }
        }
       return result;
    }
}
